package com.justnow.offer;

import org.omg.CORBA.INTERNAL;

import java.net.Inet4Address;
import java.util.*;

/**
 * @author justnow
 * Created on 2020-09-12
 * Description
 */
public class Wangyi01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        HashMap<String, Integer> map = new HashMap<>();
        int m = scanner.nextInt();
        int n = scanner.nextInt();
        ArrayList<String> array = new ArrayList<>();
        scanner.nextLine();
        for (int i = 0; i < n; i++) {
            String str = scanner.nextLine();
            String[] s = str.split(" ");
            if (s[1].equals("left")) {
                map.put(s[0] + "l", Integer.valueOf(s[2]));
            } else {
                map.put(s[0] + 'r', Integer.valueOf(s[2]));
            }
        }
        int sum = 0;
/*        for (Integer value : map.values()) {
            String keyleft = value + "l";
            String keyright = value + "r";
            if (map.containsKey(keyleft) || map.containsKey(keyright)) {
                continue;
            }
            int number= 0;
            for (String s : map.keySet()) {
                String key = s;
                int v = map.get(s);
                if (v == value) {
                    number++;
                }
                if (number == 2) {
                    break;
                }
            }
        }*/

        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            String keyleft = entry.getValue() + "l";
            String keyright = entry.getValue() + "r";
            if (map.containsKey(keyleft) || map.containsKey(keyright)) {
                continue;
            }
            int number = 0;
            char[] chars = entry.getKey().toCharArray();
            if (chars[1] == 'l') {

            }
        }
        System.out.println(sum);

    }
}
